export default class Queue<T> {
  private items: T[] = []

  // 获取队列的长度
  public get length(): number {
    return this.items.length
  }

  // 判断队列是否为空
  public get isEmpty(): boolean {
    return this.length === 0
  }

  // 入队
  push(item: T): void {
    this.items.push(item)
  }

  // 出队
  shift(): T | undefined {
    return this.items.shift()
  }

  // 获取队首元素
  peek(): T | undefined {
    return this.items[0]
  }
}
